package com.huhu.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huhu.dao.RemoteDao;
import com.huhu.entity.Remote;
import com.huhu.service.inter.NGService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by xuyi on 2016/12/29.
 */
@Service
public class NGServiceImpl implements NGService {

    @Autowired
    private RemoteDao remoteDao;

    @CacheEvict(value = "findRemote", allEntries = true)
    @Override
    public int delRemoteCache(Integer page, Integer rows) {

        return 1;
    }

    @Cacheable(value = "findRemote")
    public PageInfo<Remote> findRemote(String startDate, String endDate, Integer page, Integer rows) {
        PageHelper.startPage(page, rows, true);

        List<Remote> remotes = remoteDao.findRemote(startDate, endDate);
        return new PageInfo<>(remotes);
    }
}
